home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*________________________________________________________________
- |
- | players.c - does all the action of the game
- |
- | in here are the routines that make the mouse move, explode the
- | bombs etc. init_players, and players_action are the two
- | routines that do it.
- | Call draw_players, to draw them on your screen.
- |
- | (c) Frans van Hoesel 1994, Xtreme Graphics Software
- |
- */
-
- #include <device.h>
- #include <gl/gl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <string.h>
- #include <malloc.h>
- #include <math.h>
- #include <unistd.h>
-
- #include "io.h"
- #include "IvtoGL.h"
- #include "blixvect.h"
- #include "lod.h"
- #include "maze.h"
- #include "players.h"
- #include "rand.h"
- #include "blixsound.h"
- #include "blix.h"
- #include "blixui.h"
-
- extern node_t *the_nodes;
- extern int the_nnodes;
- extern int Lod;
- extern int putbomb;
- extern Matrix rotmat;
- int score = 0;
- int highscore = 0;
- int mouse_dead = 0;
- float trackpoint[3] = { 0 , 1, 0 }; /* the point you last clicked */
-
- /* MAXMONSTER is a limitation, to make sure we don't draw
- * too many, because that would slow down the machine quite a lot
- * (it would be nice to increase this number on fast machines)
- */
- #define MAXMONSTER 20
-
- /* type of actors involved in this game */
- enum ptypes { NONE = 0, MOUSE, FISH, BONES, SPIDER, BOMB, MUSH, LIFT,
- FIRE, DOOR };
-
- /* type of action to perform in a call to do_some_actor */
- enum atype { IDLE = 1, MAGIC, KILL };
-
-
- static void remove_player(player_t *p);
- static int randnod(void);
- static player_t *add_player(int ptyp, int currnode, int prevnode);
- static void build_fire(int nodnum, int power);
- static void init_special(void);
-
- static int allow_bombs = 0;
- static int lifts_destroyed = 0;
- static int active_lift = -1;
- static float mouse_pos[3] = { 0, 1, 0 };
- static player_t *first_player = NULL;
- static player_t *last_player = NULL;
- static player_t *null_player = NULL;
- static player_t *door_player = NULL;
- int monster_cnt = 0;
- static float prev_trackpoint[3] = {0, 1, 0};
- static player_t obj_definitions[] = {
- { /* none */
- 0, 0, 0, 0, 0, { 0, -1, 0 }, { 1, 0, 0 }, 0, 0, 0, NULL, NULL
- },
- { /* mouse */
- 1, 12, 0, 0, 0, { 0, -1, 0 }, { 0.000000, 0.850651, 0.525731 },
- 0.023, 1420, 1420, NULL, NULL
- },
- { /* fish */
- 2, 1, 0, 0, 0, { 0, -1, 0}, { 1, 0, 0}, 0.023, 900, 901, NULL, NULL
- },
- { /* bones */
- 3, 1, 0, 0, 0, { 0, -1, 0}, { 1, 0, 0}, 0.034, 300, 299, NULL, NULL
- },
- { /* spider */
- 4, 1, 0, 0, 0, { 0, -1, 0}, { 1, 0, 0}, 0.017, 900, 901, NULL, NULL
- },
- { /* bomb */
- 5, 1, 2, 0, 0, { 0, -1, 0}, { 1, 0, 0}, 0.0, 900, 901, NULL, NULL
- },
- { /* mushroom */
- 6, 1, 1, 0, 0, { 0, -1, 0}, { 1, 0, 0}, 0.0, 900, 901, NULL, NULL
- },
- { /* lift */
- 7, 1, 0, 0, 0, { 0, -1, 0}, { 1, 0, 0}, 0.0, 900, 901, NULL, NULL
- },
- { /* fire1 */
- 8, 1, 14, 0, 0, { 0, -1, 0}, { 1, 0, 0}, 0.0, 900, 901, NULL, NULL
- },
- { /* door */
- 9, 1, 0, 0, 0, { 0, -1, 0}, { 1, 0, 0}, 0.0, 900, 901, NULL, NULL
- }
- };
-
- /*__________________________________________________________________
- |
- | randnod - returns a random node
- |
- | the nodenumber returned is a free node, not on a crossing
- |
- */
-
- static int randnod(void) {
-
- int n;
- node_t *nod;
- do {
- n = (int) (random() % the_nnodes);
- nod = &(the_nodes[n]);
- } while (nod->player != null_player || nod->cnt != 2 ||
- the_nodes[nod->c[0]].player != null_player ||
- the_nodes[nod->c[1]].player != null_player ) ;
- return n;
- }
-
- /*_______________________________________________________________________
- |
- | do_step - make the actors walk
- |
- | the maze path which the monsters follow is divided into nodes; actors
- | can only do things when they are at a node. The stages in in between the
- | nodes are interpolated in this routine.
- |
- */
-
- static void do_step(player_t *p) {
- float *p1;
- float v1[3];
- float l, factor;
- node_t *nod, *pnod;
-
- nod = &(the_nodes[p->currnode]);
- p1 = nod->pos;
- pnod = &(the_nodes[p->prevnode]);
- vsub(p1, p->pos, v1);
- l = vlength(v1);
- if (l < p->speed * 1.1) {
- /* if next node is very close, step to node position */
- vcopy(p1, p->pos);
- vcross(p1, pnod->pos, p->dir);
- vcross(p1, p->dir, p->dir);
- /*vsub(p1, pnod->pos, p->dir);*/
- vnormal(p->dir);
- /* when the actor is in between two nodes, both nodes have stored
- * the actor in their player field. Remove it from the node
- * when you just left it completely
- */
- if (pnod->player->player_type == p->player_type) {
- pnod->player = null_player;
- }
- p->prevnode = p->currnode;
- } else {
- /* do an intermediate step, and adjust direction slightly */
- factor = p->speed / l;
- vscalar(v1, factor);
- vadd(p->pos, v1, p->pos);
- vnormal(p->pos);
- vsub(p1, pnod->pos, v1);
- vnormal(v1);
- vsub(v1, p->dir, v1);
- vscalar(v1, factor);
- vadd(p->dir, v1, p->dir);
- vcross(p->dir, p->pos, v1);
- vcross(p->pos, v1, p->dir);
- vnormal(p->dir);
- }
- nod->player = p;
- }
-
- /*_________________________________________________________________________
- |
- | path_to_track - find a 'good' route towards the tracking point
- |
- | It's a little recursive routine that finds the best path towards
- | the tracking point, while never step away from it. This routine
- | might be called a few times too often (I could store the path. as
- | long as the tracking point doesn't change)
- |
- */
-
- static int path_to_track(int nod, float *dist) {
- node_t *node;
-
- int nnod, i;
- float nd, nd2;
- float ndist, ldist, mdist;
-
- node = &(the_nodes[nod]);
- ndist = *dist;
- ldist = *dist;
- mdist = *dist;
- for (i=0; i <node->cnt; i++) {
- nnod = node->c[i];
- nd = vdistance2(the_nodes[nnod].pos, trackpoint);
- if (nd < ldist) {
- nd2 = nd;
- path_to_track(nnod, &nd2);
- if (nd2 < ndist) {
- ndist = nd2;
- nod = nnod;
- mdist = nd;
- } else if (nd2 == ndist && nd < mdist) {
- ndist = nd2;
- nod = nnod;
- mdist = nd;
- }
- }
- }
- *dist = ndist;
- return nod;
- }
-
- /*_________________________________________________________________________
- |
- | path_to_mouse - find a 'good' route towards the mouse
- |
- | It's a little recursive routine that finds the best path towards
- | the point, were the mouse is, while never step away from it.
- |
- */
-
- static int path_to_mouse(int nod, float *dist) {
- node_t *node;
-
- int nnod, i;
- float nd, nd2;
- float ndist, ldist, mdist;
-
- node = &(the_nodes[nod]);
- ndist = *dist;
- ldist = *dist;
- mdist = *dist;
- for (i=0; i <node->cnt; i++) {
- nnod = node->c[i];
- nd = vdistance2(the_nodes[nnod].pos, mouse_pos);
- if (nd < ldist) {
- nd2 = nd;
- path_to_mouse(nnod, &nd2);
- if (nd2 < ndist) {
- ndist = nd2;
- nod = nnod;
- mdist = nd;
- } else if (nd2 == ndist && nd < mdist) {
- ndist = nd2;
- nod = nnod;
- mdist = nd;
- }
- }
- }
- *dist = ndist;
- return nod;
- }
-
- /*________________________________________________________________________
- |
- | do_mouse - handle all the acting of the mouse
- |
- */
-
- static void do_mouse(player_t *p, int action) {
- node_t *nod, *nnod;
- int i;
- int nextnod;
- float dist, ndist;
- player_t *play;
- float v1[3], v2[3];
-
- switch (action) {
- case IDLE: /* idle */
- switch (p->stage) {
- case 12:
- /* mouse is standing still */
- if (putbomb && allow_bombs) {
- p->stage = 7;
- p->stage_cnt = -1;
- p->curr_object = 5108;
- break;
- } else {
- if (veq(trackpoint, prev_trackpoint)) {
- p->curr_object = 5101;
- if (Lod < LIVE_FIGURES) {
- p->curr_object = p->base_object;
- }
- break;
- }
- }
- case 6:
- p->stage = 0;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- p->stage++;
- /* mouse is walking and position is exactly on node */
- if (p->currnode == p->prevnode) {
- if (putbomb && allow_bombs) {
- p->stage = 7;
- p->stage_cnt = -1;
- p->curr_object = 5108;
- break;
- }
- /* find the next node that makes the distance
- * to the tracking point the closest possible
- */
- nod = &(the_nodes[p->currnode]);
- nextnod = p->currnode;
- dist = vdistance2(the_nodes[nextnod].pos, trackpoint);
- nextnod = path_to_track(p->currnode, &dist);
- play = the_nodes[nextnod].player;
- if (play != null_player) {
- if ((play->player_type == SPIDER ||
- play->player_type == FISH ||
- play->player_type == BONES) &&
- !mouse_dead ) {
- /* you just stepped into a deadly monster */
- sfx(SFX_DONK);
- do_mouse(p, KILL);
- return ;
- } else if (play->player_type == DOOR ||
- play->player_type == MUSH) {
- /* your path is blocked, but do the
- * step that makes your distance to the
- * trackpoint smaller
- */
- nextnod = p->currnode;
- dist = vdistance2(the_nodes[nextnod].pos,
- trackpoint);
- i = 0;
- while (i < nod->cnt) {
- if (the_nodes[nod->c[i]].player
- == null_player) {
- ndist = vdistance2(
- the_nodes[nod->c[i]].pos,
- trackpoint);
- if (ndist < dist) {
- dist = ndist;
- nextnod = nod->c[i];
- }
- }
- i++;
- }
- play = the_nodes[nextnod].player;
- if (play != null_player) {
- if ((play->player_type == SPIDER ||
- play->player_type == FISH ||
- play->player_type == BONES) &&
- !mouse_dead ) {
- /* unfortunatly you stepped the wrong
- * way
- */
- sfx(SFX_DONK);
- do_mouse(p, KILL);
- return ;
- }
- }
- } else {
- /* mouse stops moving */
- nextnod = p->currnode;
- }
-
- }
-
- if (nextnod == p->currnode) {
- /* stop moving the mouse */
- p->stage = 12;
- p->curr_object = p->base_object + 1;
- vcopy(trackpoint, prev_trackpoint);
- } else {
- /* did you step on one of the magic footsteps ? */
- if (the_nodes[nextnod].special.b.magic != 0) {
- do_player(
- the_nodes[the_nodes[nextnod].special.b.magic].player,
- MAGIC);
- }
- nnod = & (the_nodes[nextnod]);
- vsub(nnod->pos, nod->pos, v1);
- if (vdot(v1, p->dir) < -0.04) {
- if (nod->cnt >1 ) {
- if (nextnod == nod->c[0]) {
- vsub(the_nodes[nod->c[1]].pos, nnod->pos, v2);
- } else {
- vsub(the_nodes[nod->c[0]].pos, nnod->pos, v2);
- }
- vscalar(v1, 1.6);
- } else {
- vcross(nnod->pos, nod->pos, v2);
- vscalar(v1, -0.3 / vlength(v1));
- }
- vadd(v1, v2, p->dir);
- vcross(p->dir, p->pos, v1);
- vcross(p->pos, v1, p->dir);
- vnormal(p->dir);
- p->currnode = nextnod;
- } else {
- p->currnode = nextnod;
- do_step(p);
- }
- p->curr_object = p->base_object + p->stage+1;
- }
- } else {
- /* keep on walking from prevnode to currnode */
- do_step(p);
- p->curr_object = p->base_object + p->stage+1;
- }
- if (Lod < LIVE_FIGURES) {
- p->curr_object = p->base_object;
- }
- break;
- case 7:
- if (p->stage_cnt-- < 0) {
- p->stage = 8;
- p->curr_object = 5109;
- p->stage_cnt = -1;
- } else {
- p->curr_object = 5108;
- }
- break;
- case 8: /* put a bomb */
- if (p->stage_cnt-- < 0) {
- p->stage = 9;
- p->curr_object = 5110;
- p->stage_cnt = -1;
- /* find forward bend position */
- nod = the_nodes+ p->currnode;
- nextnod = p->currnode;
- dist =10;
- i = 0;
- vcopy(p->dir, v1);
- vscalar(v1, 0.1);
- vadd(p->pos, v1, v1);
- while (i < nod->cnt) {
- ndist = vdistance2(the_nodes[nod->c[i]].pos, v1);
- if (ndist < dist) {
- dist = ndist;
- nextnod = nod->c[i];
- }
- i++;
- }
- if (the_nodes[nextnod].player == null_player) {
- the_nodes[nextnod].player =
- add_player(BOMB, nextnod, p->currnode);
- } else if (the_nodes[nextnod].player->player_type == LIFT &&
- the_nodes[the_nodes[nextnod].c[1]].player ==
- null_player) {
- /* the clause makes it possible to put a bomb inside
- * a lift (there is an extra node for this in the data
- * exactly at the same possition as the lift) The node
- * to put that bomb is always in the_nodes[nextnod].c[1]
- */
- the_nodes[the_nodes[nextnod].c[1]].player =
- add_player(BOMB, the_nodes[nextnod].c[1],
- nextnod);
- }
- } else {
- p->curr_object = 5109;
- }
- break;
- case 9:
- if (p->stage_cnt-- < 0) {
- p->stage = 10;
- p->curr_object = 5109;
- p->stage_cnt = -1;
- } else {
- p->curr_object = 5110;
- }
- break;
- case 10:
- if (p->stage_cnt-- < 0) {
- p->stage = 11;
- p->curr_object = 5108;
- p->stage_cnt = -1;
- } else {
- p->curr_object = 5109;
- }
- break;
- case 11:
- if (p->stage_cnt-- < 0) {
- p->stage = 12;
- p->curr_object = 5101;
- p->stage_cnt = 0;
- putbomb = 0;
- } else {
- p->curr_object = 5108;
- }
- break;
- } /* switch stage */
- break;
- case KILL:
- /* you are dead!
- * Note that the mouse_dead variable is incremented at each frame
- * to do some animation in the dead phase. That animations is
- * a later hack, and didn't fit well in the do_mouse routine.
- */
- if (!mouse_dead) {
- mouse_dead = 1;
- }
- break;
- } /* switch action */
-
- /* record the mouse position, so the monster know how to hunt you */
- mouse_pos[0] = p->pos[0];
- mouse_pos[1] = p->pos[1];
- mouse_pos[2] = p->pos[2];
- }
-
-
- /*_________________________________________________________________________
- |
- | do_fish - make the fish fly
- |
- | this routine isn't much different from do_spider or do_bones
- | (there are slight variations to give each monster some character)
- */
-
- static void do_fish(player_t *p, int action) {
- node_t *nod;
- int i;
- int nextnod;
- float dist, ndist;
- player_t *play;
- float v1[3];
-
- switch (action) {
- case 1: /* idle */
- switch (p->stage) {
- case 7:
- p->stage = 0;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- if (p->currnode == p->prevnode) {
- /* find the next node that makes the distance
- * to the tracking point the closest possible
- */
- nod = the_nodes+ p->currnode;
- nextnod = p->currnode;
- dist =10;
- i = (int) random() % 20;
- /* if you are on a crossing make the fish walk
- * towards the mouse, or let it walk straight ahead
- * in its current direction
- */
- if (nod->cnt > 2 && i < 5 + lifts_destroyed / 5) {
- /* walk in the direction of the mouse; however
- * there is a small change to do a random step
- */
- if ( i == 0) {
- v1[0] = frand();
- v1[1] = v1[0]+0.0001;
- v1[2] = v1[1];
- vnormal(v1);
- }
- vcopy(mouse_pos, v1);
- } else {
- vadd(p->pos, p->dir, v1);
- }
- i = 0;
-
- while (i < nod->cnt) {
- play = the_nodes[nod->c[i]].player;
- if (play != null_player && play->player_type != MOUSE) {
- i++;
- continue;
- }
-
- ndist = vdistance2(the_nodes[nod->c[i]].pos, v1);
- if (ndist < dist) {
- dist = ndist;
- nextnod = nod->c[i];
- }
- i++;
- }
- if (nextnod == p->currnode) {
- /* stop moving the fish */
- p->stage++;
- } else {
- p->stage++;
- p->currnode = nextnod;
- if (the_nodes[nextnod].player->player_type
- == MOUSE) {
- do_step(p);
- sfx(SFX_DONK);
- do_mouse(the_nodes[nextnod].player, KILL);
- }
- vsub(the_nodes[nextnod].pos,
- the_nodes[p->prevnode].pos, v1);
- if (vdot(v1, p->dir) < 0) {
- vcross(the_nodes[nextnod].pos,
- the_nodes[p->prevnode].pos, p->dir);
- vnormal(v1);
- vscalar(v1, -0.3);
- vadd(p->dir, v1, p->dir);
- vnormal(p->dir);
- }
- do_step(p);
- p->curr_object = p->base_object + p->stage;
- }
- } else {
- /* keep on walking from prevnode to currnode */
- p->stage++;
- do_step(p);
- p->curr_object = p->base_object + p->stage;
- }
- if (Lod < LIVE_FIGURES) {
- p->curr_object = p->base_object;
- }
- break;
- case 8:
- if (p->stage_cnt--< 0) {
- the_nodes[p->currnode].player = null_player;
- remove_player(p);
- monster_cnt --;
- } else {
- p->curr_object = 5208;
- }
- } /* switch stage */
- break;
- case KILL:
- if (p->stage != 8) {
- p->stage = 8;
- p->curr_object = 5208;
- p->stage_cnt = 13;
- score += 50;
- }
- break;
- } /* switch action */
- ;
- }
-
-
- /*_______________________________________________________________________
- |
- | do_bones - handle the very fast bones figure
- |
- | this routines is very much like do_fish or do_spider
- */
-
- static void do_bones(player_t *p, int action) {
- node_t *nod;
- int i;
- int nextnod;
- float dist, ndist;
- player_t *play;
- float v1[3];
-
- switch (action) {
- case IDLE: /* idle */
- switch (p->stage) {
- case 6:
- p->stage = 0;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- if (p->currnode == p->prevnode) {
- /* find the next node that makes the distance
- * to the tracking point the closest possible
- */
- nod = the_nodes+ p->currnode;
- nextnod = p->currnode;
- dist =10;
- i = (int) random() % 20;
- if (nod->cnt > 2 && i < 5 + lifts_destroyed / 10) {
- if ( i == 0) {
- v1[0] = frand();
- v1[1] = v1[0]+0.0001;
- v1[2] = v1[1];
- vnormal(v1);
- }
- vcopy(mouse_pos, v1);
- } else {
- vadd(p->pos, p->dir, v1);
- }
- i = 0;
- while (i < nod->cnt) {
- play = the_nodes[nod->c[i]].player;
- if (play != null_player && play->player_type != MOUSE) {
- i++;
- continue;
- }
-
- ndist = vdistance2(the_nodes[nod->c[i]].pos, v1);
- if (ndist < dist) {
- dist = ndist;
- nextnod = nod->c[i];
- }
- i++;
- }
- if (nextnod == p->currnode) {
- /* stop moving the bones */
- p->stage++;
- } else {
- p->stage++;
- p->currnode = nextnod;
- if (the_nodes[nextnod].player->player_type
- == MOUSE) {
- do_step(p);
- sfx(SFX_DONK);
- do_mouse(the_nodes[nextnod].player, KILL);
- }
- vsub(the_nodes[nextnod].pos,
- the_nodes[p->prevnode].pos, v1);
- if (vdot(v1, p->dir) < 0) {
- vcross(the_nodes[nextnod].pos,
- the_nodes[p->prevnode].pos, p->dir);
- vnormal(v1);
- vscalar(v1, -0.3);
- vadd(p->dir, v1, p->dir);
- vnormal(p->dir);
- }
- do_step(p);
- p->curr_object = p->base_object + p->stage;
- }
- } else {
- /* keep on walking from prevnode to currnode */
- p->stage++;
- do_step(p);
- p->curr_object = p->base_object + p->stage;
- }
- if (Lod < LIVE_FIGURES) {
- p->curr_object = p->base_object;
- }
- break;
- case 7:
- /* killed, showing score */
- if (p->stage_cnt-- < 0) {
- the_nodes[p->currnode].player = 0;
- remove_player(p);
- monster_cnt--;
- return;
- } else {
- p->curr_object = 5307;
- }
- break;
- } /* switch stage */
- break;
- case KILL:
- if (p->stage != 7) {
- p->stage = 7;
- p->stage_cnt = 13;
- p->curr_object = 5307;
- score += 100;
- }
- break;
- } /* switch action */
- ;
- }
-
-
- /*________________________________________________________________________
- |
- | do_spider - slow but nasty
- |
- | this routines looks like do_fish or do_bones
- |
- */
-
- static void do_spider(player_t *p, int action) {
- node_t *nod;
- int i;
- int nextnod;
- float dist, ndist;
- player_t *play;
- float v1[3];
-
- switch (action) {
- case IDLE: /* idle */
- switch (p->stage) {
- case 8:
- p->stage = 0;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- if (p->currnode == p->prevnode) {
- /* find the next node that makes the distance
- * to the tracking point the closest possible
- */
- nod = the_nodes+ p->currnode;
- nextnod = p->currnode;
- dist =10;
- i = (int) random() % 20;
- if (nod->cnt > 2 && i < 8 + lifts_destroyed / 4) {
- if ( i == 0) {
- v1[0] = frand();
- v1[1] = v1[0]+0.0001;
- v1[2] = v1[1];
- vnormal(v1);
- } else if (i < 5) {
- /* this makes the spider even smarter */
- nextnod = p->currnode;
- dist = vdistance2(the_nodes[nextnod].pos,
- mouse_pos);
- nextnod = path_to_track(p->currnode, &dist);
- if (nextnod != p->currnode &&
- the_nodes[nextnod].player == null_player) {
- i = -1; /* mis-use i as a flag */
- } else {
- dist = 10;
- vcopy(mouse_pos, v1);
- }
- } else {
- vcopy(mouse_pos, v1);
- }
- } else {
- vadd(p->pos, p->dir, v1);
- }
- if (i != -1 ) {
- i = 0;
- while (i < nod->cnt) {
- play = the_nodes[nod->c[i]].player;
- if (play != null_player && play->player_type != MOUSE) {
- i++;
- continue;
- }
-
- ndist = vdistance2(the_nodes[nod->c[i]].pos, v1);
- if (ndist < dist) {
- dist = ndist;
- nextnod = nod->c[i];
- }
- i++;
- }
- }
- if (nextnod == p->currnode) {
- /* stop moving the spider */
- p->stage++;
- } else {
- p->stage++;
- p->currnode = nextnod;
- if (the_nodes[nextnod].player->player_type
- == MOUSE) {
- do_step(p);
- sfx(SFX_DONK);
- do_mouse(the_nodes[nextnod].player, KILL);
- }
- vsub(the_nodes[nextnod].pos,
- the_nodes[p->prevnode].pos, v1);
- if (vdot(v1, p->dir) < 0) {
- vcross(the_nodes[nextnod].pos,
- the_nodes[p->prevnode].pos, p->dir);
- vnormal(v1);
- vscalar(v1, -0.3);
- vadd(p->dir, v1, p->dir);
- vnormal(p->dir);
- }
- do_step(p);
- p->curr_object = p->base_object + p->stage;
- }
- } else {
- /* keep on walking from prevnode to currnode */
- p->stage++;
- do_step(p);
- p->curr_object = p->base_object + p->stage;
- }
- if (Lod < LIVE_FIGURES) {
- p->curr_object = p->base_object;
- }
- break;
- case 9:
- if (p->stage_cnt--< 0) {
- the_nodes[p->currnode].player = null_player;
- remove_player(p);
- monster_cnt--;
- } else {
- p->curr_object = 5409;
- }
- } /* switch stage */
- break;
- case KILL:
- if (p->stage != 9) {
- p->stage = 9;
- p->curr_object = 5409;
- p->stage_cnt = 13;
- score += 25;
- }
- break;
-
- } /* switch action */
- }
-
-
- /*________________________________________________________________________
- |
- | do_fire - do the simple but beatiful fire animation
- |
- */
-
- static void do_fire(player_t *p, int action) {
- /* there is currently only one action */
- switch (action) {
- case IDLE: /* idle */
- if (p->stage_cnt-- < 0) {
- the_nodes[p->currnode].player = 0;
- remove_player(p);
- } else {
- if (p->stage_cnt >= 0) {
- p->curr_object++;
- if (p->curr_object == 5804)
- p->curr_object = 5801;
- } else {
- p->curr_object = 5800;
- }
- }
- break;
- } /* switch action */
-
- }
-
-
- /*________________________________________________________________________
- |
- | do_mushroom - rather static animation
- |
- | this animation justs grows a mushroom, and after a period of time
- | let it grow at a different, random position
- |
- */
-
- static void do_mushroom(player_t *p, int action) {
-
- int nodenum;
-
- switch (action) {
- case IDLE: /* idle */
- switch (p->stage) {
- case 1:
- if (p->stage_cnt-- < 0) {
- p->stage++;
- p->curr_object = 5602;
- p->stage_cnt = 2;
- } else {
- p->curr_object = 5601;
- }
- break;
- case 2:
- if (p->stage_cnt-- < 0) {
- p->stage++;
- p->curr_object = 5603;
- p->stage_cnt = 2;
- } else {
- p->curr_object = 5602;
- }
- break;
- case 3:
- if (p->stage_cnt--< 0) {
- p->stage = 6;
- p->curr_object = 5604;
- p->stage_cnt = 20 + (int)(random() % 250);
- } else {
- p->curr_object = 5603;
- }
- break;
- case 6:
- if (p->stage_cnt--< 0) {
- p->stage = 7;
- p->curr_object = 5603;
- p->stage_cnt = 2;
- } else {
- p->curr_object = 5604;
- }
- break;
- case 7:
- if (p->stage_cnt--< 0) {
- p->stage = 8;
- p->curr_object = 5602;
- p->stage_cnt = 2;
- } else {
- p->curr_object = 5603;
- }
- break;
- case 8:
- if (p->stage_cnt--< 0) {
- p->stage = 4;
- p->curr_object = 5601;
- p->stage_cnt = 2;
- } else {
- p->curr_object = 5602;
- }
- break;
- case 5:
- /* showing score */
- if (p->stage_cnt-- >= 0) {
- p->curr_object = 5605;
- return;
- }
- /* else run through */
- case 4:
- if (p->stage_cnt-- < 0) {
- the_nodes[p->currnode].player = null_player;
- nodenum = randnod();
- p->currnode = nodenum;
- p->prevnode = nodenum;
- p->stage_cnt = 2;
- p->curr_object = 5601;
- p->stage = 1;
- vcopy (the_nodes[nodenum].pos, p->pos);
- the_nodes[nodenum].player = p;
- vdirection(p->pos,
- the_nodes[the_nodes[nodenum].c[0]].pos, p->dir);
- } else {
- p->curr_object = 5601;
- }
-
- } /* switch stage */
- if (Lod < LIVE_FIGURES) {
- p->curr_object = p->base_object;
- }
- break;
- case KILL:
- if (p->stage != 5) {
- p->stage = 5;
- p->curr_object = 5605;
- p->stage_cnt = 13;
- score +=10;
- }
- break;
- } /* action switch */
- }
-
-
- /*________________________________________________________________________
- |
- | do_bomb - animate the bomb
- |
- | let it grow, animate the fire, and explode. When it explodes, it calls
- | build_fire, to give it the destructive power, normaly assiociated with
- | this type of equipment. This bomb is however fireproof, in that it does
- | not explode when heated in the fire of other bombs.
- |
- */
-
- static void do_bomb(player_t *p, int action) {
- int nodn;
- int power;
- float x;
-
-
- switch (action) {
- case IDLE: /* idle */
- switch (p->stage) {
- case 1:
- if (p->stage_cnt-- < 0) {
- p->stage++;
- p->stage_cnt = 0;
- p->curr_object = 5502;
- } else {
- p->curr_object = 5501;
- }
- break;
- case 2:
- if (p->stage_cnt-- < 0) {
- p->stage++;
- p->stage_cnt = 0;
- p->curr_object = 5503;
- } else {
- p->curr_object = 5502;
- }
- break;
- case 3:
- if (p->stage_cnt-- < 0) {
- p->stage++;
- p->stage_cnt = 8;
- p->curr_object = 5504;
- } else {
- p->curr_object = 5503;
- }
- break;
- case 4:
- if (p->stage_cnt-- < 0) {
- p->stage++;
- p->stage_cnt = 8;
- p->curr_object = 5506;
- } else {
- p->curr_object = 5504 + (p->stage_cnt & 1);
- }
- break;
- case 5:
- if (p->stage_cnt-- < 0) {
- p->stage++;
- p->stage_cnt = 8;
- p->curr_object = 5508;
- } else {
- p->curr_object = 5506 + (p->stage_cnt & 1);
- }
- break;
- case 6:
- if (p->stage_cnt-- < 0) {
- p->stage++;
- p->stage_cnt = 8;
- p->curr_object = 5510;
- } else {
- p->curr_object = 5507 + (p->stage_cnt & 1);
- }
- break;
- case 7:
- if (p->stage_cnt-- < 0) {
- p->stage++;
- p->stage_cnt = 8;
- p->curr_object = 5511;
- } else {
- p->curr_object = 5510 + (p->stage_cnt & 1);
- }
- break;
- case 8:
- /* explode */
- /* find position of explosion */
- x = rotmat[0][0] * p->pos[0] + rotmat[1][0] * p->pos[1] +
- rotmat[2][0] * p->pos[2];
- if (x < -0.3) {
- x = -1;
- } else if (x > 0.3) {
- x = 1;
- } else
- x = 0;
- sfx_pan(SFX_EXPLOSION, (int) x);
- power = (int)(random() % 3) + 4;
- the_nodes[p->currnode].player = 0;
- nodn = p->currnode;
- remove_player(p);
- build_fire(nodn, power);
- return;
- case 9:
- /* do nothing */
- ;
- break;
- }
- }
- if (Lod < LIVE_FIGURES) {
- p->curr_object = p->base_object;
- }
- }
-
-
- /*________________________________________________________________
- |
- | build_fire - create the nodes that show the fireballs
- |
- | this is a little recursive routine, that buils the fire on
- | selected nodes, starting from the node given as parameter.
- | Fire does not go through the door of the elevator, everything
- | else (except fire itself) is simply killed)
- |
- */
-
- static void build_fire(int nodnum, int power) {
- node_t *nod;
- int i;
- int nextn;
- player_t *play;
-
- nod = &(the_nodes[nodnum]);
- if (--power < 0 || nod->player->player_type == DOOR)
- return;
- if (nod->player->player_type != FIRE) {
- play = add_player(FIRE, nodnum, nod->c[0]);
- play->curr_object = 5801 + power % 3;
- } else {
- nod->player->stage_cnt = obj_definitions[FIRE].stage_cnt;
- }
- for (i = 0; i < nod->cnt; i++) {
- nextn = nod->c[i];
- if (the_nodes[nextn].player != null_player) {
- do_player(the_nodes[nextn].player, KILL);
- }
- }
- for (i=0; i< nod->cnt; i++) {
- build_fire(nod->c[i], power);
- }
- }
-
-
- /*_________________________________________________________________________
- |
- | do_lift - make the lift behave as it should
- |
- | it pops up the elevator, opens the doors, creates monsters, closes the
- | door, and has some tricky handling to make a door impossible to
- | penetrate when it is closed.
- |
- */
-
- static void do_lift(player_t *p, int action) {
- int monster;
- player_t *newp;
- int door;
- int nodenum;
- float x;
-
- switch (action) {
- case IDLE: /* idle */
- switch (p->stage) {
-
- case 1:
- /* lift is inactive */
- p->curr_object = 5706;
- break;
- case 2:
- if (p->stage_cnt-- < 0) {
- p->stage = 3;
- p->stage_cnt = 4;
- p->curr_object = 5702;
- /* pick a monster to generate */
- if (monster_cnt < MAXMONSTER ) {
- monster = (int)(random() %
- (25 + lifts_destroyed));
-
- if (monster >= 24 || lifts_destroyed == 11) {
- monster = BONES;
-
- } else if (monster >= 19 ) {
- monster = FISH;
- } else {
- monster = SPIDER;
- }
- /* don't created a monster when something else is
- * at that position (bomb, mouse, other monster )
- */
- if (the_nodes[the_nodes[p->currnode].c[0]].player ==
- null_player) {
- newp = add_player(monster,
- the_nodes[p->currnode].c[0],
- the_nodes[the_nodes[p->currnode].c[0]].c[0]
- );
- newp->stage_cnt = 20;
- }
- monster_cnt++;
- }
- } else {
- p->curr_object = 5701;
- }
- break;
- case 3:
- if (p->stage_cnt-- < 0) {
- p->stage = 4;
- p->stage_cnt = 4;
- p->curr_object = 5703;
- } else {
- p->curr_object = 5702;
- }
- break;
- case 4:
- if (p->stage_cnt-- < 0) {
- p->curr_object = 5704;
- /* open the door, by removing the DOOR actor */
- door = the_nodes[the_nodes[p->currnode].c[0]].c[0];
- the_nodes[door].player = null_player;
- p->stage_cnt = 30 + (int)(random() %
- (60- 2*lifts_destroyed));
- p->stage = 5;
- } else {
- p->curr_object = 5703;
- }
- break;
- case 5:
- if (p->stage_cnt-- < 0 ) {
- door = the_nodes[the_nodes[p->currnode].c[0]].c[0];
- if (the_nodes[door].player != null_player) {
- /* cannot close the door someone is blocking */
- return;
- }
- the_nodes[door].player = door_player;
- p->stage++;
- p->stage_cnt = 3;
- p->curr_object = 5703;
- } else {
- p->curr_object = 5704;
- }
- break;
- case 6:
- if (p->stage_cnt-- < 0) {
- p->stage++;
- p->stage_cnt = 3;
- p->curr_object = 5702;
- } else {
- p->curr_object = 5703;
- }
- break;
- case 7:
- if (p->stage_cnt-- < 0) {
- /* if another elevator is active, and nothing is trapped
- * inside then close down this elevator.
- */
- if (p->currnode != active_lift &&
- (the_nodes[the_nodes[p->currnode].c[0]].player ==
- null_player) &&
- (the_nodes[the_nodes[p->currnode].c[1]].player ==
- null_player)) {
- /* shut down this lift */
- p->stage=11;
- p->stage_cnt = 2;
- p->curr_object = 5700;
- allow_bombs = 1;
- } else {
- /* else set up the elevator to open again
- * after some random interval, which gets
- * shorter during the game
- */
- p->stage = 2;
- p->stage_cnt = 60 - lifts_destroyed * 2.5 +
- (int)(random() % (40 - lifts_destroyed * 2));
- p->curr_object = 5701;
- }
- } else {
- p->curr_object = 5702;
- }
- break;
- case 8:
- if (p->stage_cnt-- < 0) {
- door = the_nodes[the_nodes[p->currnode].c[0]].c[0];
- if (the_nodes[door].player != null_player &&
- the_nodes[door].player->player_type != DOOR) {
- /* cannot close the door someone is blocking */
- do_player(the_nodes[door].player, KILL);
- }
- p->stage = 9;
- p->curr_object = 5705;
- the_nodes[door].player = door_player;
- } else {
- p->curr_object = 5707;
- }
- break;
- case 9:
- /* crashed and stay crashed */
- p->curr_object = 5705;
- break;
- case 10:
- if (p->stage_cnt-- < 0) {
- p->stage = 2;
- p->stage_cnt = 20 + (int)(random() % 20) - lifts_destroyed;
- p->curr_object = 5701;
- }
- break;
- case 11:
- if (p->stage_cnt-- < 0) {
- p->stage = 1;
- p->curr_object = 5706;
- }
- break;
- case 12:
- if (p->stage_cnt-- < 0) {
- p->stage = 2;
- p->stage_cnt = 20 - lifts_destroyed +
- (int)(random() % (20 - lifts_destroyed));
- p->curr_object = 5701;
-
- } else {
- p->curr_object = 5700;
- }
- break;
- case 13:
- /* special case, pops up elevator, generate mouse
- * and closes down elevator as soon as mouse leaves
- * the elevator; some trickery is involved
- * to prevent bombs during this stage
- */
- if (p->stage_cnt-- < 0) {
- p->stage = 14;
- p->stage_cnt = 2;
- p->curr_object = 5700;
- sfx_pan(SFX_LIFT, 0);
- } else {
- active_lift = -1;
- p->curr_object = 5706;
- }
- break;
- case 14:
- if (p->stage_cnt-- < 0) {
- p->stage = 15;
- p->stage_cnt = 2;
- p->curr_object = 5702;
- /* pick a monster to generate */
- newp = add_player(MOUSE,
- the_nodes[p->currnode].c[0],
- the_nodes[the_nodes[p->currnode].c[0]].c[0]);
- newp->stage_cnt = 10;
- } else {
- p->curr_object = 5701;
- }
- break;
- case 15:
- if (p->stage_cnt-- < 0) {
- p->stage = 16;
- p->stage_cnt = 2;
- p->curr_object = 5703;
- } else {
- p->curr_object = 5702;
- }
- break;
- case 16:
- if (p->stage_cnt-- < 0) {
- p->curr_object = 5704;
- /* open the door, by removing the DOOR actor */
- door = the_nodes[the_nodes[p->currnode].c[0]].c[0];
- the_nodes[door].player = null_player;
- p->stage_cnt = 0;
- p->stage = 17;
- trackpoint[0] = 0; trackpoint[1] = 0; trackpoint[2] = 1;
- } else {
- p->curr_object = 5703;
- }
- break;
- case 17:
- /* wait for mouse to leave elevator */
- door = the_nodes[the_nodes[p->currnode].c[0]].c[0];
- if (the_nodes[door].player == null_player &&
- (the_nodes[the_nodes[p->currnode].c[0]].player ==
- null_player) && the_nodes[door].player ==
- null_player) {
- the_nodes[door].player = door_player;
- p->stage = 18;
- p->stage_cnt = 2;
- p->curr_object = 5703;
- } else {
- p->curr_object = 5704;
- }
- break;
- case 18:
- if (p->stage_cnt-- < 0) {
- p->stage = 7;
- p->stage_cnt = 2;
- p->curr_object = 5702;
- putbomb = 0;
- } else {
- p->curr_object = 5703;
- }
- break;
- } /* switch stage */
- break;
- case MAGIC:
- /* you have stepped on a magic node, so pop up the elevator */
- switch (p->stage) {
- case 1:
- /* find position of lift on screen */
- x = rotmat[0][0] * p->pos[0] + rotmat[1][0] * p->pos[1] +
- rotmat[2][0] * p->pos[2];
- if (x < -0.3) {
- x = -1;
- } else if (x > 0.3) {
- x = 1;
- } else
- x = 0;
- sfx_pan(SFX_LIFT, (int) x);
- p->stage = 12;
- active_lift = p->currnode;
- p->stage_cnt = 0;
- p->curr_object = 5700;
- /* add a few mushrooms to make the game more difficult */
- nodenum = randnod();
- add_player(MUSH, nodenum, nodenum);
- nodenum = randnod();
- add_player(MUSH, nodenum, nodenum);
- break;
- }
- break;
- case KILL:
- if (p->stage != 8) {
- p->stage = 8;
- p->curr_object = 5707;
- p->stage_cnt = 13;
- score += 250;
- lifts_destroyed++;
- if (lifts_destroyed == 12) {
- /* end of this level */
- /* this is real silly and has to improve a lot */
- sleep(3);
- sfx(SFX_BEEP);
- sleep(2);
- printf("\nyou finished the demo level\n");
- printf("\nYour score was: %d (not so bad)\n", score);
- printf("\n\nthank you for playing.\n");
- printf("\n Frans van Hoesel Xtreme Graphics Software\n");
- printf("\n (hoesel@chem.rug.nl)");
- gexit();
- end_sound();
- exit(0);
- }
- }
- break;
-
- } /* switch action */
-
- }
-
-
- /*__________________________________________________________________________
- |
- | do_player - depending on the type of actor, call the correct routine
- |
- */
-
- void do_player(player_t *p, int action) {
- switch (p->player_type) {
- case MOUSE: /* mouse */
- do_mouse(p, action);
- break;
- case FISH: /* fish */
- do_fish(p, action);
- break;
- case BONES: /* bones */
- do_bones(p, action);
- break;
- case SPIDER: /* spider */
- do_spider(p, action);
- break;
- case BOMB: /* bomb */
- do_bomb(p, action);
- break;
- case MUSH: /* mushroom */
- do_mushroom(p, action);
- break;
- case LIFT: /* lift */
- do_lift(p, action);
- break;
- case FIRE: /* fire */
- do_fire(p, action);
- break;
- /* case DOOR is not needed */
- } /* switch player_type */
- }
-
-
- /*_________________________________________________________________________
- |
- | add_player - make a new actor
- |
- */
-
- static player_t *add_player(int ptyp, int currnode, int prevnode) {
- player_t *newplayer;
-
- newplayer = (player_t *) malloc (sizeof(player_t));
- memcpy(newplayer, obj_definitions + ptyp, sizeof(player_t));
- last_player->next = newplayer;
- newplayer->prev = last_player;
- last_player = newplayer;
- vcopy(the_nodes[currnode].pos, newplayer->pos);
- vdirection(the_nodes[prevnode].pos, the_nodes[currnode].pos,
- newplayer->dir);
- if (newplayer->stage_cnt < 0) {
- newplayer->stage_cnt = (int)(random() % (- newplayer->stage_cnt))
- - newplayer->stage_cnt / 4;
- }
- if (newplayer->speed == 0) {
- newplayer->prevnode = currnode;
- } else {
- newplayer->prevnode = prevnode;
- }
- the_nodes[currnode].player = newplayer;
- newplayer->currnode = currnode;
- return newplayer;
- }
-
-
- /*_________________________________________________________________________
- |
- | remove_player - delete an actor
- |
- */
-
- static void remove_player(player_t *p) {
- if (p == last_player) {
- last_player = p->prev;
- }
- /* prevnode and currnode may be equal... who cares */
- the_nodes[p->currnode].player = null_player;
- the_nodes[p->prevnode].player = null_player;
- if (p->next != NULL) {
- p->next->prev = p->prev;
- }
- p->prev->next = p->next;
- free (p);
- }
-
-
- /*_________________________________________________________________________
- |
- | players_action - let all defined actors do some animation
- |
- */
-
- void players_action(void) {
- player_t *play;
- play = first_player->next;
- /* if you are dead, keep animating possible fire; the rest doesn't
- * animate anymore
- */
- if (mouse_dead) {
- do {
- if (play->player_type == FIRE) {
- do_player(play, IDLE);
- }
- play = play->next;
- } while (play != NULL);
- } else {
- do {
- do_player(play, IDLE);
- play = play->next;
- } while (play != NULL);
- }
- }
-
-
- /*_________________________________________________________________________
- |
- | draw_players - draw all defined actors
- |
- | it also does some trivial culling. for this it needs the actual
- | height of the actors. When the level of detail is very low, so the
- | walls are just lines, you may see the effect of culling a bit too
- | early, but this I thought was acceptable.
- */
-
- void draw_players(Matrix mat, Matrix invmat) {
-
- Matrix m;
-
- player_t *play, *p;
- float *p1, *d1, v1[3];
- static float height[] = { 0, -0.33, -0.3, -0.35, -0.08, -0.17,
- -0.2, -0.38, -0.2, 0};
-
- if (mouse_dead != 0) {
- if (mouse_dead >= 25) {
- putbomb = 0;
- if (mouse_dead == 25) {
- play = first_player->next;
- do {
- p = play->next;
- free(p);
- play = p;
- } while (play != NULL);
- memcpy(first_player, obj_definitions, sizeof(player_t));
- last_player = first_player;
- null_player = first_player;
- last_player = first_player;
- init_special();
- monster_cnt = 0;
- lifts_destroyed = 0;
- active_lift = -1;
- }
- trackpoint[0] = 0; trackpoint[1] = 1; trackpoint[2] = 0;
- prev_trackpoint[0] = 0; prev_trackpoint[1] = 1; prev_trackpoint[2] = 0;
- if (score > highscore) {
- highscore = score;
- }
- return;
- } else if (mouse_dead == 6) {
- sfx(SFX_PLANET);
- }
- }
- multmatrix(mat);
- play = first_player->next;
- m[0][3] = 0;
- m[1][3] = 0;
- m[2][3] = 0;
- m[3][0] = 0;
- m[3][1] = 0;
- m[3][2] = 0;
- m[3][3] = 1;
- do {
- if (play->player_type == DOOR) {
- play = play->next;
- continue;
- }
- p1 = play->pos;
- /* some crude culling for the backside of the sphere */
- if ( invmat[2][0]* p1[0] + invmat[2][1] * p1[1] + invmat[2][2] * p1[2]
- < height[play->player_type]) {
- play = play->next;
- continue;
- }
- d1 = play->dir;
- pushmatrix();
- translate(p1[0], p1[1], p1[2]);
- vcross(p1, d1, v1);
- vnormal(v1);
- m[0][0] = v1[0];
- m[0][1] = v1[1];
- m[0][2] = v1[2];
- m[1][0] = p1[0];
- m[1][1] = p1[1];
- m[1][2] = p1[2];
- m[2][0] = d1[0];
- m[2][1] = d1[1];
- m[2][2] = d1[2];
- multmatrix(m);
- callobj(play->curr_object);
- play = play->next;
- popmatrix();
- } while (play != NULL);
- }
-
- /*________________________________________________________________________
- |
- | draw_status - status indicator, during loading of data
- |
- */
-
- static void draw_status(int i) {
- ortho2(0,300, 0, 300);
- cpack(0x000020ff);
- rectf(174, 100, 286, 111);
- cpack(0x00009090);
- rectf(175,101, 285, 110);
- cpack(0x00004090);
- #ifdef ANIMATED
- rectf(175, 101, 175+i*110/67.0, 110);
- #else
- rectf(175, 101, 175+i*110/37.0, 110);
- #endif
- }
-
-
- /*_________________________________________________________________________
- |
- | init_players - initialize all the players data
- |
- | read the object definitions from the data files; update the
- | status display, and when there are redraw, or quit events during this
- | phase, act accordingly.
- |
- */
- void init_players(void) {
- int obj;
- int cnt = 0;
-
- /*mallopt(M_MXFAST, sizeof(player_t))
- mallopt(M_FREEHD, 1)
- */;
-
- obj = 5800;
- obj_definitions[8].base_object = obj;
- obj_definitions[8].curr_object = obj+1; draw_status(cnt++); do_event();
- read_object_file("obj/fire0.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/fire1.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/fire2.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/fire3.iv", obj++); draw_status(cnt++); do_event();
-
- obj = 5100;
- obj_definitions[1].base_object = obj;
- obj_definitions[1].curr_object = obj+1;
- read_object_file("obj/mouseblok.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/mouse0.iv", obj++); draw_status(cnt++); do_event();
- #ifdef ANIMATED
- read_object_file("obj/mouse1.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/mouse2.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/mouse3.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/mouse4.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/mouse5.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/mouse6.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/mousea.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/mouseb.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/mousec.iv", obj++); draw_status(cnt++); do_event();
- #else
- makeobj(obj++); callobj(5101); closeobj();
- makeobj(obj++); callobj(5101); closeobj();
- makeobj(obj++); callobj(5101); closeobj();
- makeobj(obj++); callobj(5101); closeobj();
- makeobj(obj++); callobj(5101); closeobj();
- makeobj(obj++); callobj(5101); closeobj();
- makeobj(obj++); callobj(5101); closeobj();
- makeobj(obj++); callobj(5101); closeobj();
- makeobj(obj++); callobj(5101); closeobj();
- #endif
-
- obj = 5200;
- obj_definitions[2].base_object = obj;
- obj_definitions[2].curr_object = obj+1;
- read_object_file("obj/fishblok.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/fish1.iv", obj++); draw_status(cnt++); do_event();
- #ifdef ANIMATED
- read_object_file("obj/fish2.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/fish3.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/fish4.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/fish5.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/fish6.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/fish7.iv", obj++); draw_status(cnt++); do_event();
- #else
- makeobj(obj++); callobj(5201); closeobj();
- makeobj(obj++); callobj(5201); closeobj();
- makeobj(obj++); callobj(5201); closeobj();
- makeobj(obj++); callobj(5201); closeobj();
- makeobj(obj++); callobj(5201); closeobj();
- makeobj(obj++); callobj(5201); closeobj();
- #endif
- read_object_file("obj/50.iv", obj++); draw_status(cnt++); do_event();
-
- obj = 5300;
- obj_definitions[3].base_object = obj;
- obj_definitions[3].curr_object = obj+1;
- read_object_file("obj/bonesblok.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/bones1.iv", obj++); draw_status(cnt++); do_event();
- #ifdef ANIMATED
- read_object_file("obj/bones2.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/bones3.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/bones4.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/bones5.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/bones6.iv", obj++); draw_status(cnt++); do_event();
- #else
- makeobj(obj++); callobj(5301); closeobj();
- makeobj(obj++); callobj(5301); closeobj();
- makeobj(obj++); callobj(5301); closeobj();
- makeobj(obj++); callobj(5301); closeobj();
- makeobj(obj++); callobj(5301); closeobj();
- #endif
- read_object_file("obj/100.iv", obj++); draw_status(cnt++); do_event();
-
- obj = 5400;
- obj_definitions[4].base_object = obj;
- obj_definitions[4].curr_object = obj+1;
- read_object_file("obj/spiderblok.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/spider9.iv", obj++); draw_status(cnt++); do_event();
- #ifdef ANIMATED
- read_object_file("obj/spider2.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/spider3.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/spider4.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/spider5.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/spider6.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/spider7.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/spider8.iv", obj++); draw_status(cnt++); do_event();
- #else
- makeobj(obj++); callobj(5401); closeobj();
- makeobj(obj++); callobj(5401); closeobj();
- makeobj(obj++); callobj(5401); closeobj();
- makeobj(obj++); callobj(5401); closeobj();
- makeobj(obj++); callobj(5401); closeobj();
- makeobj(obj++); callobj(5401); closeobj();
- makeobj(obj++); callobj(5401); closeobj();
- #endif
- read_object_file("obj/25.iv", obj++); draw_status(cnt++); do_event();
-
- obj = 5500;
- obj_definitions[5].base_object = obj;
- obj_definitions[5].curr_object = obj+1;
- read_object_file("obj/bombblok.iv", obj++); draw_status(cnt++); do_event();
- #ifdef ANIMATED
- read_object_file("obj/bomba.iv", obj++);
- read_object_file("obj/bombb.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/bombc.iv", obj++);
- read_object_file("obj/bomb1.iv", obj++);
- read_object_file("obj/bomb2.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/bomb3.iv", obj++);
- read_object_file("obj/bomb4.iv", obj++);
- read_object_file("obj/bomb5.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/bomb6.iv", obj++);
- read_object_file("obj/bomb7.iv", obj++);
- read_object_file("obj/bomb8.iv", obj++); draw_status(cnt++); do_event();
- #else
- read_object_file("obj/bomb1.iv", obj++);
- makeobj(obj++); callobj(5501); closeobj();
- makeobj(obj++); callobj(5501); closeobj();
- makeobj(obj++); callobj(5501); closeobj();
- makeobj(obj++); callobj(5501); closeobj();
- makeobj(obj++); callobj(5501); closeobj();
- makeobj(obj++); callobj(5501); closeobj();
- makeobj(obj++); callobj(5501); closeobj();
- makeobj(obj++); callobj(5501); closeobj();
- makeobj(obj++); callobj(5501); closeobj();
- makeobj(obj++); callobj(5501); closeobj();
- #endif
- read_object_file("obj/15.iv", obj++); draw_status(cnt++); do_event();
-
- obj = 5600;
- obj_definitions[6].base_object = obj;
- obj_definitions[6].curr_object = obj+4;
- read_object_file("obj/mushblok.iv", obj++); draw_status(cnt++); do_event();
- #ifdef ANIMATED
- read_object_file("obj/mushr1.iv", obj++);
- read_object_file("obj/mushr2.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/mushr3.iv", obj++);
- read_object_file("obj/mushr4.iv", obj++); draw_status(cnt++); do_event();
- #else
- read_object_file("obj/mushr4.iv", obj++); draw_status(cnt++); do_event();
- makeobj(obj++); callobj(5601); closeobj();
- makeobj(obj++); callobj(5601); closeobj();
- makeobj(obj++); callobj(5601); closeobj();
- #endif
- read_object_file("obj/10.iv", obj++); draw_status(cnt++); do_event();
-
- obj = 5700;
- obj_definitions[7].base_object = obj;
- obj_definitions[7].curr_object = obj+1;
- read_object_file("obj/lift5.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/lift0.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/lift1.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/lift2.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/lift3.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/lift4.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/lift6.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/250.iv", obj++); draw_status(cnt++); do_event();
-
- obj = 7000;
- read_object_file("obj/dead.iv", obj++); draw_status(cnt++); do_event();
-
- obj = 8000;
- read_object_file("obj/0.iv", obj++);
- read_object_file("obj/1.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/2.iv", obj++);
- read_object_file("obj/3.iv", obj++);
- read_object_file("obj/4.iv", obj++);
- read_object_file("obj/5.iv", obj++); draw_status(cnt++); do_event();
- read_object_file("obj/6.iv", obj++);
- read_object_file("obj/7.iv", obj++);
- read_object_file("obj/8.iv", obj++);
- read_object_file("obj/9.iv", obj++); draw_status(cnt++); do_event();
-
-
- /* add the mouse as a predefined player */
- first_player = (player_t *) malloc (sizeof(player_t));
- memcpy(first_player, obj_definitions, sizeof(player_t));
- last_player = first_player;
- null_player = first_player;
- /* time to make a pass over the nodes and to
- * create some initial monsters
- */
- init_special();
- }
-
-
- /*_________________________________________________________________________
- |
- | init_special - relate the node data to the actor data
- |
- | for all nodes in the data base, created an actor or a magic node
- */
-
- static void init_special(void) {
- node_t *nod;
- special_t spec;
- int i;
-
- nod = the_nodes;
- for (i=0; i< the_nnodes; i++) {
- spec = nod->special;
-
- if (spec.all) {
- if (spec.b.ptype != 0) {
- if (spec.b.ndir != 0 ) {
- /* point to previous node */
- nod->player = add_player(spec.b.ptype, i, nod->c[1]);
- } else {
- /* point to next node */
- nod->player = add_player(spec.b.ptype, i, nod->c[0]);
- }
- if (spec.b.ptype == DOOR) {
- door_player = nod->player;
- } else if (spec.b.ptype == MUSH) {
- nod->player->stage = 6;
- nod->player->stage_cnt = random() % 150 + 40;
- }
- } else {
- nod->player = null_player;
- }
- } else {
- nod->player = null_player;
- }
- nod++;
- }
- nod = & the_nodes[1420];
- nod->player->stage = 13;
- active_lift = -1;
- nod->player->stage_cnt = 5;
- nod->player->curr_object = 5706;
- allow_bombs = 0;
- }
-